/*
 * 主界面
 * 
 */
Ext.define('BenBen.App', {
    extend: 'Ext.ux.desktop.App',

    requires: [
        'Ext.window.MessageBox',
        'Ext.ux.desktop.ShortcutModel',
        'BenBen.modules.project.operation.OperationWorkModule',
        'BenBen.modules.system.SystemModule',
        'BenBen.modules.external.supplier.SupplierModule'
    ],

    init: function() {
        // custom logic before getXYZ methods get called...

        this.callParent();
        this.desktop.initShortcut();
        // now ready...
    },
    /**
     * 开始菜单内容
     */
    getModules : function(){
        return [
            new BenBen.modules.project.operation.OperationWorkModule(),
            new BenBen.modules.system.SystemModule(),
            new BenBen.modules.external.supplier.SupplierModule()
        ];
    },
    /**
     * 桌面显示部分
     */
    getDesktopConfig: function () {
        var me = this, ret = me.callParent();
        
        var data = getTopModules();
        
        
        return Ext.apply(ret, {
            //cls: 'ux-desktop-black',
            contextMenuItems: [
                { text: '更改设置', handler: me.onSettings, scope: me }
            ],
            shortcuts: Ext.create('Ext.data.Store', {
                model: 'Ext.ux.desktop.ShortcutModel',
                data : data
//                data: [
//                    { name: '系统管理', iconCls: 'setting-shortcut', module: 'system-win' },
//                    { name: '组织架构', iconCls: 'department-shortcut', module: 'department-win' },
////                    { name: '用户管理', iconCls: 'user-shortcut', module: 'user-win' },
////                    { name: '客户管理', iconCls: 'customer-shortcut', module: 'customer-win' },
//                    { name: '工作清单', iconCls: 'product-shortcut', module: 'operationWork-win' },
////                    { name: '订单管理', iconCls: 'order-shortcut', module: '' },
////                    { name: '竞争对手', iconCls: 'competitor-shortcut', module: '' },
////                    { name: '信息交流', iconCls: 'chat-shortcut', module: '' },
////                    { name: '日程安排', iconCls: 'calendar-shortcut', module: '' },
////                    { name: '我的联系人', iconCls: 'linker-shortcut', module: '' },
////                    { name: '文件库', iconCls: 'folder-shortcut', module: '' },
//                    { name: '报表中心', iconCls: 'chart-shortcut', module: '' }
//                ]
            }),
            wallpaper: 'images/wallpapers/desktop.jpg',
            wallpaperStretch: false
        });
    },

    /**
     * 开始菜单
     */
    getStartConfig : function() {
        var me = this, ret = me.callParent();

        return Ext.apply(ret, {
            title: '无标题',
            iconCls: 'user',
            height: 300,
            toolConfig: {
                width: 100,
                items: [
                    {
                        text:'设置',
                        iconCls:'settings',
                        handler: me.onSettings,
                        scope: me
                    },
                    '-',
                    {
                        text:'登出',
                        iconCls:'logout',
                        handler: me.onLogout,
                        scope: me
                    }
                ]
            }
        });
    },
    
    /**
     * 快捷栏
     */
    getTaskbarConfig: function () {
        var ret = this.callParent();
        return Ext.apply(ret, {
            quickStart: [
                { name: '折叠窗口', iconCls: 'accordion', module: 'acc-win' },
                { name: '表格窗口', iconCls: 'icon-grid', module: 'grid-win' }
            ],
            trayItems: [
                { xtype: 'trayclock', flex: 1 }
            ]
        });
    },

    onLogout: function () {
        Ext.Msg.confirm('登出', '确定登出?');
    },

    onSettings: function () {
        var dlg = new MyDesktop.Settings({
            desktop: this.desktop
        });
        dlg.show();
    }
});
